import { Controller } from "../../mvc/core/Controller";
import { DataEvent } from "../events/DataEvent";
import { GroupHintIcon } from "../view/group/GroupHintIcon";
import { GroupRequestWindow } from "../view/group/GroupRequestWindow";
import { IView } from "../../mvc/interfaces/IView";
import { GroupModuleNew } from "../../../modules/GroupModuleNew";
import { GModuleEvent } from "../mvc/GModuleEvent";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { GameMapUtil } from "../scene/map/GameMapUtil";
import { GameProxy } from "../mvc/GameProxy";
import { AutoFight } from "../view/autoFight/AutoFight";
import { DataProvider } from "../../../fl/data/DataProvider";
import { SPublicMiniPlayer } from "../../../Message/Public/SPublicMiniPlayer";
import { EntityUtil } from "../scene/layer/utils/EntityUtil";
import { SGroupSetting } from "../../../Message/Public/SGroupSetting";
import { SystemSetter } from "../view/system/SystemSetter";
import { SGroupInvite } from "../../../Message/Public/SGroupInvite";
import { EGroupMsgType } from "../../../Message/Public/EGroupMsgType";
import { SGroupInviteEx } from "../../../Message/Public/SGroupInviteEx";
import { UiHintIconView } from "../view/uiIconBtn/UiHintIconView";
import { SEntityId } from "../../../Message/Public/SEntityId";
import { MsgManager } from "../manager/MsgManager";
import { Language } from "../../../extend/language/Language";
import { CopyUtil } from "../view/copy/CopyUtil";
import { Alert } from "../../../com/mui/controls/Alert";
import { IGroupModuleNew } from "../../../modules/interfaces/IGroupModuleNew";
type int = number;
//class GroupController
    
    export  class GroupController extends Controller
    {
       

        /* internal  */onGroupAgreeHandlerCross(arg1: DataEvent): void
        {
            var loc1=arg1.data["isInvite"] as Boolean;
            var loc2=arg1.data["data"];
            var loc3=loc1 != true ? GroupController.Type_apply : GroupController.Type_invite;
            this.doAgreeCross(loc3, loc2);
            this.openWinCross();
            return;
        }

        /* internal  */onGroupRefuseHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["isInvite"] as Boolean;
            var loc2=arg1.data["data"];
            var loc3=loc1 != true ? GroupController.Type_apply : GroupController.Type_invite;
            this.doReject(loc3, loc2);
            this.openWin();
            return;
        }

        /* internal  */onGroupRefuseHandlerCross(arg1: DataEvent): void
        {
            var loc1=arg1.data["isInvite"] as Boolean;
            var loc2=arg1.data["data"];
            var loc3=loc1 != true ? GroupController.Type_apply : GroupController.Type_invite;
            this.doRejectCross(loc3, loc2);
            this.openWinCross();
            return;
        }

        /* internal  */onGroupRefuseAllHandler(arg1: DataEvent): void
        {
            var loc4=null;
            var loc1=arg1.data["isInvite"] as Boolean;
            var loc2=arg1.data["dataArray"];
            var loc3=loc1 != true ? GroupController.Type_apply : GroupController.Type_invite;
            var loc5=0;
            var loc6=loc2;
            for(loc4 of loc6) 
            {
                this.doReject(loc3, loc4);
            }
            this.groupRequestWindow.updateDataProvider([], true);
            this.groupRequestWindow.hide();
            this.groupHintIcon.updateNum();
            return;
        }

        /* internal  */onGroupRefuseAllHandlerCross(arg1: DataEvent): void
        {
            var loc4=null;
            var loc1=arg1.data["isInvite"] as Boolean;
            var loc2=arg1.data["dataArray"];
            var loc3=loc1 != true ? GroupController.Type_apply : GroupController.Type_invite;
            var loc5=0;
            var loc6=loc2;
            for(loc4 of loc6) 
            {
                this.doRejectCross(loc3, loc4);
            }
            this.crossGroupRequestWindow.updateDataProvider([], true);
            this.crossGroupRequestWindow.hide();
            this.crossGroupHintIcon.updateNum();
            return;
        }

        public get groupHintIcon(): GroupHintIcon
        {
            if (!this._groupHintIcon) 
            {
                this._groupHintIcon = new GroupHintIcon(false);
            }
            return this._groupHintIcon;
        }

        public get crossGroupHintIcon(): GroupHintIcon
        {
            if (!this._crossGroupHintIcon) 
            {
                this._crossGroupHintIcon = new GroupHintIcon(true);
            }
            return this._crossGroupHintIcon;
        }

        public get groupRequestWindow(): GroupRequestWindow
        {
            if (!this._groupRequestWindow) 
            {
                this._groupRequestWindow = new GroupRequestWindow(false);
            }
            return this._groupRequestWindow;
        }

        public get crossGroupRequestWindow(): GroupRequestWindow
        {
            if (!this._crossGroupRequestWindow) 
            {
                this._crossGroupRequestWindow = new GroupRequestWindow(true);
            }
            return this._crossGroupRequestWindow;
        }

        protected /* override */ initView(): IView
        {
            if (!this._groupModule) 
            {
                this._groupModule = new GroupModuleNew();
                this._groupModule.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
                this._groupModule.addEventListener(GModuleEvent.Event_KickOut, this.doKickout);
                this._groupModule.addEventListener(GModuleEvent.Event_LeaveGroup, this.leaveGroup);
                this._groupModule.addEventListener(GModuleEvent.Event_CrossKickOut, this.doKickoutCross);
                this._groupModule.addEventListener(GModuleEvent.Event_CrossLeaveGroup, this.leaveGroupCross);
                Dispatcher.addEventListener(EventName.Scene_Update, this.onSceneUpdate);
            }
            return this._groupModule;
        }

        protected /* override */ initServer(): void
        {
            Dispatcher.addEventListener(EventName.Group_DoCreateGroup, this.doCreateGroup);
            Dispatcher.addEventListener(EventName.Group_DoApply, this.doApply);
            Dispatcher.addEventListener(EventName.Group_DoInvite, this.doInvite);
            Dispatcher.addEventListener(EventName.Group_OpenWin, this.openWin);
            Dispatcher.addEventListener(EventName.Group_DoKickOut, this.doKickout);
            Dispatcher.addEventListener(EventName.Group_DoLeaveGroup, this.leaveGroup);
            Dispatcher.addEventListener(EventName.Group_DoChangeCaptain, this.doChangeCaptain);
            Dispatcher.addEventListener(EventName.Group_Agree, this.onGroupAgreeHandler);
            Dispatcher.addEventListener(EventName.Group_Refuse, this.onGroupRefuseHandler);
            Dispatcher.addEventListener(EventName.Group_RefuseAll, this.onGroupRefuseAllHandler);
            NetDispatcher.addCmdListener(ServerCommand.Group_Apply, this.onApply);
            NetDispatcher.addCmdListener(ServerCommand.Group_Invite, this.onInvite);
            NetDispatcher.addCmdListener(ServerCommand.Group_PlayerInfoChange, this.onPlayerInfoChange);
            NetDispatcher.addCmdListener(ServerCommand.Group_CaptainChange, this.onPlayerInfoChange);
            NetDispatcher.addCmdListener(ServerCommand.Group_GroupSetting, this.onGroupSettingChange);
            Dispatcher.addEventListener(EventName.CrossGroup_DoCreateGroup, this.doCreateGroupCross);
            Dispatcher.addEventListener(EventName.CrossGroup_DoApply, this.doApplyCross);
            Dispatcher.addEventListener(EventName.CrossGroup_DoInvite, this.doInviteCross);
            Dispatcher.addEventListener(EventName.CrossGroup_OpenWin, this.openWinCross);
            Dispatcher.addEventListener(EventName.CrossGroup_DoKickOut, this.doKickoutCross);
            Dispatcher.addEventListener(EventName.CrossGroup_DoLeaveGroup, this.leaveGroupCross);
            Dispatcher.addEventListener(EventName.CrossGroup_DoChangeCaptain, this.doChangeCaptainCross);
            Dispatcher.addEventListener(EventName.CrossGroup_Agree, this.onGroupAgreeHandlerCross);
            Dispatcher.addEventListener(EventName.CrossGroup_Refuse, this.onGroupRefuseHandlerCross);
            Dispatcher.addEventListener(EventName.CrossGroup_RefuseAll, this.onGroupRefuseAllHandlerCross);
            NetDispatcher.addCmdListener(ServerCommand.CrossGroup_Apply, this.onApplyCross);
            NetDispatcher.addCmdListener(ServerCommand.CrossGroup_Invite, this.onInviteCross);
            NetDispatcher.addCmdListener(ServerCommand.CrossGroup_PlayerInfoChange, this.onPlayerInfoChangeCross);
            NetDispatcher.addCmdListener(ServerCommand.CrossGroup_CaptainChange, this.onPlayerInfoChangeCross);
            NetDispatcher.addCmdListener(ServerCommand.CrossGroup_GroupSetting, this.onGroupSettingChangeCross);
            Dispatcher.addEventListener(EventName.SetAutoFightSuccess, this.onAutoFightSetChange);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            this._groupModule.isCrossGroupMap = GameMapUtil.isCrossGroupMap();
            this.onPlayerInfoChange();
            this.onPlayerInfoChangeCross();
            this._groupModule.refreshNearbyList();
            return;
        }

        /* internal  */doCreateGroup(arg1: DataEvent): void
        {
            if (!cache.group.isInGroup) 
            {
                GameProxy.groupProxy.createGroup(cache.group.memberInvite, AutoFight.localAutoFight.acceptTeam);
            }
            return;
        }

        /* internal  */doCreateGroupCross(arg1: DataEvent): void
        {
            if (!cache.crossGroup.isInGroup) 
            {
                GameProxy.crossGroupProxy.createGroup(cache.crossGroup.memberInvite, AutoFight.localAutoFight.acceptTeam);
            }
            return;
        }

        /* internal  */openWin(arg1: Object /* flash.events.Event */=null): void
        {
            var loc1=0;
            var loc2=undefined;
            var loc3="";
            var loc4;
            if ((loc4 = cache.group).inviteList.length > 0) 
            {
                this.groupRequestWindow.updateDataProvider(loc4.inviteList, true);
                this.groupRequestWindow.show();
                return;
            }
            if (loc4.applyList.length > 0) 
            {
                this.groupRequestWindow.updateDataProvider(loc4.applyList, false);
                this.groupRequestWindow.show();
                return;
            }
            this.groupRequestWindow.hide();
            this.updateInviteData();
            return;
        }

        /* internal  */openWinCross(arg1: Object /* flash.events.Event */=null): void
        {
            var loc1=0;
            var loc2=undefined;
            var loc3="";
            var loc4;
            if ((loc4 = cache.crossGroup).inviteList.length > 0) 
            {
                this.crossGroupRequestWindow.updateDataProvider(loc4.inviteList, true);
                this.crossGroupRequestWindow.show();
                return;
            }
            if (loc4.applyList.length > 0) 
            {
                this.crossGroupRequestWindow.updateDataProvider(loc4.applyList, false);
                this.crossGroupRequestWindow.show();
                return;
            }
            this.crossGroupRequestWindow.hide();
            return;
        }

        /* internal  */onPlayerInfoChange(arg1: Object=null): void
        {
            var loc1=false;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=null;
            var loc7=false;
            var loc8=false;
            if (this._groupModule && !this._groupModule.isHide) 
            {
                loc1 = cache.group.isCaptain;
                this._groupModule.isCaptain = loc1;
                loc2 = cache.group.players;
                loc3 = new DataProvider();
                loc4 = [];
                loc5 = 0;
                while (loc5 < loc2.length) 
                {
                    loc6 = loc2[loc5] as SPublicMiniPlayer;
                    loc7 = EntityUtil.equal(loc6.entityId, cache.role.entityInfo.entityId);
                    loc8 = cache.group.captain && EntityUtil.equal(cache.group.captain, loc6.entityId);
                    loc3.addItem({"type":"", "online": loc6.online, "isCaption": loc8, "isCrossGroup": false, "captainMode": loc1, "isMySelf": loc7, "player": loc6});
                    ++loc5;
                }
                loc3.sortOn(["isCaption", "online"], Array.DESCENDING);
                this._groupModule.updateGroupList(loc3);
                this._groupModule.refreshNearbyList();
                if (cache.group.players.length > 0) 
                {
                    cache.group.inviteList = [];
                    this.updateInviteData();
                }
                if (cache.group.players.length > 0 && !(cache.group.captain.id == cache.role.entityInfo.entityId.id)) 
                {
                    cache.group.applyList = [];
                    this.updateApplyData();
                }
            }
            if (this.groupRequestWindow && this.groupRequestWindow.isHide == false) 
            {
                if (cache.group.players.length > 0) 
                {
                    cache.group.inviteList = [];
                    this.updateInviteData();
                    this.openWin();
                }
            }
            return;
        }

        /* internal  */onPlayerInfoChangeCross(arg1: Object=null): void
        {
            var loc1=false;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=null;
            var loc7=false;
            var loc8=false;
            if (this._groupModule && !this._groupModule.isHide) 
            {
                loc1 = cache.crossGroup.isCaptain;
                this._groupModule.isCaptainCross = loc1;
                loc2 = cache.crossGroup.players;
                loc3 = new DataProvider();
                loc4 = [];
                loc5 = 0;
                while (loc5 < loc2.length) 
                {
                    loc6 = loc2[loc5] as SPublicMiniPlayer;
                    loc7 = EntityUtil.equal(loc6.entityId, cache.role.entityInfo.entityId);
                    loc8 = cache.crossGroup.captain && EntityUtil.equal(cache.crossGroup.captain, loc6.entityId);
                    loc3.addItem({"type":"", "online": loc6.online, "isCaption": loc8, "isCrossGroup": true, "captainMode": loc1, "isMySelf": loc7, "player": loc6});
                    ++loc5;
                }
                loc3.sortOn(["isCaption", "online"], Array.DESCENDING);
                this._groupModule.updateCrossGroupList(loc3);
                this._groupModule.refreshNearbyList();
                if (cache.crossGroup.players.length > 0) 
                {
                    cache.crossGroup.inviteList = [];
                    this.updateCrossInviteData();
                }
                if (cache.crossGroup.players.length > 0 && !loc1) 
                {
                    cache.crossGroup.applyList = [];
                    this.updateCrossApplyData();
                }
            }
            if (this._crossGroupRequestWindow && this._crossGroupRequestWindow.isHide == false) 
            {
                if (cache.crossGroup.players.length > 0) 
                {
                    cache.crossGroup.inviteList = [];
                    this.updateCrossInviteData();
                    this.openWinCross();
                }
            }
            return;
        }

        /* internal  */onGroupSettingChange(arg1: SGroupSetting): void
        {
            if (this._groupModule && !this._groupModule.isHide) 
            {
                this._groupModule.updateGroupSetStatus();
            }
            return;
        }

        /* internal  */onGroupSettingChangeCross(arg1: SGroupSetting): void
        {
            if (this._groupModule && !this._groupModule.isHide) 
            {
                this._groupModule.updateGroupSetStatus();
            }
            return;
        }

        /* internal  */updateInviteData(): void
        {
            this.groupHintIcon.updateNum();
            return;
        }

        /* internal  */updateCrossInviteData(): void
        {
            this.crossGroupHintIcon.updateNum();
            return;
        }

        /* internal  */updateApplyData(): void
        {
            this.groupHintIcon.updateNum();
            return;
        }

        /* internal  */updateCrossApplyData(): void
        {
            this.crossGroupHintIcon.updateNum();
            return;
        }

        /* internal  */onInvite(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            if (SystemSetter.currentSetter.refuseTeam) 
            {
                if (typeof arg1 === "sgroupinvite") 
                {
                    loc1 = arg1 as SGroupInvite;
                    GameProxy.groupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                }
                else if (typeof arg1 === "sgroupinviteex") 
                {
                    loc2 = arg1 as SGroupInviteEx;
                    GameProxy.groupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                }
                cache.group.removeFromInviteList(arg1);
                return;
            }
            if (AutoFight.currentAutoFight.isAutoFight && AutoFight.currentAutoFight.acceptTeam) 
            {
                if (typeof arg1 === "sgroupinvite") 
                {
                    loc1 = arg1 as SGroupInvite;
                    GameProxy.groupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                }
                else if (typeof arg1 === "sgroupinviteex") 
                {
                    loc2 = arg1 as SGroupInviteEx;
                    GameProxy.groupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                }
                cache.group.removeFromInviteList(arg1);
                return;
            }
            UiHintIconView.instance.addHintIcon(this.groupHintIcon);
            this.updateInviteData();
            return;
        }

        /* internal  */onInviteCross(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            if (SystemSetter.currentSetter.refuseTeam) 
            {
                if (typeof arg1 === "sgroupinvite") 
                {
                    loc1 = arg1 as SGroupInvite;
                    GameProxy.crossGroupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                }
                else if (typeof arg1 === "sgroupinviteex") 
                {
                    loc2 = arg1 as SGroupInviteEx;
                    GameProxy.crossGroupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                }
                cache.crossGroup.removeFromInviteList(arg1);
                return;
            }
            if (AutoFight.currentAutoFight.isAutoFight && AutoFight.currentAutoFight.acceptTeam) 
            {
                if (typeof arg1 === "sgroupinvite") 
                {
                    loc1 = arg1 as SGroupInvite;
                    GameProxy.crossGroupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                }
                else if (typeof arg1 === "sgroupinviteex") 
                {
                    loc2 = arg1 as SGroupInviteEx;
                    GameProxy.crossGroupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                }
                cache.crossGroup.removeFromInviteList(arg1);
                return;
            }
            UiHintIconView.instance.addHintIcon(this.crossGroupHintIcon);
            this.updateCrossInviteData();
            return;
        }

        /* internal  */onApply(arg1: Object): void
        {
            var loc1=null;
            if (SystemSetter.currentSetter.refuseTeam && cache.group.players.length == 0) 
            {
                loc1 = arg1 as SGroupInvite;
                GameProxy.groupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                cache.group.removeFromApplyList(loc1);
                return;
            }
            if (AutoFight.currentAutoFight.isAutoFight && AutoFight.currentAutoFight.acceptTeam) 
            {
                loc1 = arg1 as SGroupInvite;
                GameProxy.groupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                cache.group.removeFromApplyList(loc1);
                return;
            }
            UiHintIconView.instance.addHintIcon(this.groupHintIcon);
            this.updateApplyData();
            return;
        }

        /* internal  */onApplyCross(arg1: Object): void
        {
            var loc1=null;
            if (SystemSetter.currentSetter.refuseTeam && cache.group.players.length == 0) 
            {
                loc1 = arg1 as SGroupInvite;
                GameProxy.crossGroupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                cache.crossGroup.removeFromApplyList(loc1);
                return;
            }
            if (AutoFight.currentAutoFight.isAutoFight && AutoFight.currentAutoFight.acceptTeam) 
            {
                loc1 = arg1 as SGroupInvite;
                GameProxy.crossGroupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                cache.crossGroup.removeFromApplyList(loc1);
                return;
            }
            UiHintIconView.instance.addHintIcon(this.crossGroupHintIcon);
            this.updateCrossApplyData();
            return;
        }

        /* internal  */doChangeCaptain(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPublicMiniPlayer;
            GameProxy.groupProxy.modifyCaptain(loc1.entityId);
            return;
        }

        /* internal  */doChangeCaptainCross(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPublicMiniPlayer;
            GameProxy.crossGroupProxy.modifyCaptain(loc1.entityId);
            return;
        }

        /* internal  */onAutoFightSetChange(arg1: DataEvent): void
        {
            if (cache.group.isCaptain && !(cache.group.autoEnter == AutoFight.localAutoFight.acceptTeam)) 
            {
                cache.group.autoEnter = AutoFight.localAutoFight.acceptTeam;
                if (this._groupModule) 
                {
                    this._groupModule.updateGroupSetStatus();
                    this._groupModule.updateGroupSet();
                }
            }
            return;
        }

        /* internal  */onSceneUpdate(arg1: DataEvent): void
        {
            if (this._groupModule) 
            {
                this._groupModule.isCrossGroupMap = GameMapUtil.isCrossGroupMap();
                this._groupModule.refreshNearbyList();
            }
            return;
        }

        /* internal  */doApply(arg1: DataEvent): void
        {
            var loc1=arg1.data as SEntityId;
            if (EntityUtil.equal(loc1, cache.role.entityInfo.entityId)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62016));
            }
            else 
            {
                GameProxy.groupProxy.apply(loc1);
            }
            return;
        }

        /* internal  */doApplyCross(arg1: DataEvent): void
        {
            var loc1=arg1.data as SEntityId;
            if (EntityUtil.equal(loc1, cache.role.entityInfo.entityId)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62016));
            }
            else 
            {
                GameProxy.crossGroupProxy.apply(loc1);
            }
            return;
        }

        /* internal  */doInvite(arg1: DataEvent): void
        {
            var loc1=arg1.data as SEntityId;
            if (cache.group.players.length >= 5) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62018));
            }
            else if (EntityUtil.equal(loc1, cache.role.entityInfo.entityId)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62019));
            }
            else 
            {
                GameProxy.groupProxy.invite(loc1);
            }
            return;
        }

        /* internal  */doInviteCross(arg1: DataEvent): void
        {
            var loc1=arg1.data as SEntityId;
            if (cache.crossGroup.players.length >= 5) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62305));
            }
            else if (EntityUtil.equal(loc1, cache.role.entityInfo.entityId)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62019));
            }
            else 
            {
                GameProxy.crossGroupProxy.invite(loc1);
            }
            return;
        }

        /* internal  */doAgree(arg1: int, arg2): void
        {
            var loc1=null;
            var loc2=null;
            if (cache.group.players.length >= 5) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62020));
                return;
            }
            if (arg1 != GroupController.Type_apply) 
            {
                if (typeof arg2 === "sgroupinvite") 
                {
                    loc1 = arg2 as SGroupInvite;
                    GameProxy.groupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                    cache.group.removeFromInviteList(loc1);
                }
                else 
                {
                    loc2 = arg2 as SGroupInviteEx;
                    GameProxy.groupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                    cache.group.removeFromInviteList(loc2);
                }
                this.updateInviteData();
            }
            else 
            {
                loc1 = arg2 as SGroupInvite;
                GameProxy.groupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                cache.group.removeFromApplyList(loc1);
                this.updateApplyData();
            }
            this.groupHintIcon.updateNum();
            return;
        }

        /* internal  */doAgreeCross(arg1: int, arg2): void
        {
            var loc1=null;
            var loc2=null;
            if (cache.crossGroup.players.length >= 5) 
            {
                MsgManager.showRollTipsMsg(Language.getString(62306));
                return;
            }
            if (arg1 != GroupController.Type_apply) 
            {
                if (typeof arg2 === "sgroupinvite") 
                {
                    loc1 = arg2 as SGroupInvite;
                    GameProxy.crossGroupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                    cache.crossGroup.removeFromInviteList(loc1);
                }
                else 
                {
                    loc2 = arg2 as SGroupInviteEx;
                    GameProxy.crossGroupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                    cache.crossGroup.removeFromInviteList(loc2);
                }
                this.updateCrossInviteData();
            }
            else 
            {
                loc1 = arg2 as SGroupInvite;
                GameProxy.crossGroupProxy.agree(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                cache.crossGroup.removeFromApplyList(loc1);
                this.updateCrossApplyData();
            }
            this.crossGroupHintIcon.updateNum();
            return;
        }

        /* internal  */doReject(arg1: int, arg2): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1 != GroupController.Type_apply) 
            {
                if (typeof arg2 === "sgroupinvite") 
                {
                    loc1 = arg2 as SGroupInvite;
                    cache.group.removeFromInviteList(loc1);
                    GameProxy.groupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                }
                else 
                {
                    loc2 = arg2 as SGroupInviteEx;
                    cache.group.removeFromInviteList(loc2);
                    GameProxy.groupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                }
                this.updateInviteData();
            }
            else 
            {
                loc1 = arg2 as SGroupInvite;
                cache.group.removeFromApplyList(loc1);
                GameProxy.groupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                this.updateApplyData();
            }
            this.groupHintIcon.updateNum();
            return;
        }

        /* internal  */doRejectCross(arg1: int, arg2): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1 != GroupController.Type_apply) 
            {
                if (typeof arg2 === "sgroupinvite") 
                {
                    loc1 = arg2 as SGroupInvite;
                    cache.crossGroup.removeFromInviteList(loc1);
                    GameProxy.crossGroupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc1.player.entityId, loc1.certId);
                }
                else 
                {
                    loc2 = arg2 as SGroupInviteEx;
                    cache.crossGroup.removeFromInviteList(loc2);
                    GameProxy.crossGroupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeInvite), loc2.groupInfo.captainId, loc2.certId);
                }
                this.updateCrossInviteData();
            }
            else 
            {
                loc1 = arg2 as SGroupInvite;
                cache.crossGroup.removeFromApplyList(loc1);
                GameProxy.crossGroupProxy.reject_async(EGroupMsgType.convert(EGroupMsgType._EGroupMsgTypeApply), loc1.player.entityId, loc1.certId);
                this.updateCrossApplyData();
            }
            this.crossGroupHintIcon.updateNum();
            return;
        }

        /* internal  */leaveGroup(arg1: DataEvent): void
        {
            var e: DataEvent;

            var loc1;
            e = arg1;
            if (cache.copy.isInCopy && CopyUtil.isCopy(cache.copy.copyInfo) && !(cache.copy.copyInfo.singleMode == 1)) 
            {
                Alert.show(Language.getString(62022), Language.getString(69900), Alert.OK | Alert.CANCEL, null, (arg1: int): void
                {
                    if (arg1 == Alert.OK) 
                    {
                        doLeaveGroup();
                    }
                    return;
                })
            }
            else 
            {
                this.doLeaveGroup();
            }
            return;
        }

        /* internal  */doLeaveGroup(): void
        {
            GameProxy.groupProxy.left();
            return;
        }

        /* internal  */leaveGroupCross(arg1: DataEvent): void
        {
            var e: DataEvent;

            var loc1;
            e = arg1;
            if (cache.copy.isInCopy && CopyUtil.isCrossCopy(cache.copy.copyInfo) && !(cache.copy.copyInfo.singleMode == 1) && !cache.copy.isPractice) 
            {
                Alert.show(Language.getString(62307), Language.getString(69900), Alert.OK | Alert.CANCEL, null, (arg1: int): void
                {
                    if (arg1 == Alert.OK) 
                    {
                        doLeaveGroupCross();
                    }
                    return;
                })
            }
            else 
            {
                this.doLeaveGroupCross();
            }
            return;
        }

        /* internal  */doLeaveGroupCross(): void
        {
            GameProxy.crossGroupProxy.left();
            return;
        }

        /* internal  */doKickout(arg1: DataEvent): void
        {
            var loc1=arg1.data as SEntityId;
            GameProxy.groupProxy.kickOut(loc1);
            return;
        }

        /* internal  */doKickoutCross(arg1: DataEvent): void
        {
            var loc1=arg1.data as SEntityId;
            GameProxy.crossGroupProxy.kickOut(loc1);
            return;
        }

        /* internal  */onGroupAgreeHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["isInvite"] as Boolean;
            var loc2=arg1.data["data"];
            var loc3=loc1 != true ? GroupController.Type_apply : GroupController.Type_invite;
            this.doAgree(loc3, loc2);
            this.openWin();
            return;
        }

        public static /* const */Type_invite: int=0;

        public static /* const */Type_apply: int=1;

        private /* var */_groupModule: IGroupModuleNew;

        private /* var */_groupHintIcon: GroupHintIcon;

        private /* var */_groupRequestWindow: GroupRequestWindow;

        private /* var */_crossGroupHintIcon: GroupHintIcon;

        private /* var */_crossGroupRequestWindow: GroupRequestWindow;
    }
